import request from "@/utils/request";

export interface ProductCategoryQuery extends PageQuery {
  page?: number;
  limit?: number;
  keywords?: string;
  shop_id?: number;
  type?: string;
}

export interface ProductCategoryForm {
  id?: number;
  // type?: number;
  title?: string;
  thumb?: string;
  status?: number;
  shop_id?: number;
  sort?: number;
}

export interface ProductCategoryPageVO {
  id?: number;
  sort?: number;
  type?: number;
  pid?: number;
  shop_id?: number;
  title?: string;
  thumb?: string;
  shop_title?: string;
  status?: number;
  create_time?: Date;
}

const baseUri = "/mv1/api/product/category";

export function productCategoryList(query: ProductCategoryQuery) {
  return request({
    url: baseUri + "/",
    method: "get",
    params: query,
  });
}

export function getSupplierOptions() {
  return request({
    url: baseUri + "/options",
    method: "get",
    // params: query,
  });
}

export function categoryDetail(id: number) {
  return request({
    url: baseUri + "/detail/" + id,
    method: "get",
  });
}

export function createProductCategory(data: ProductCategoryForm) {
  return request({
    url: baseUri + "/add",
    method: "post",
    data: data,
  });
}

export function updateProductCategory(id: number, data: ProductCategoryForm) {
  return request({
    url: baseUri + "/edit/" + id,
    method: "put",
    data: data,
  });
}

export function deleteProductCategory(id: number) {
  return request({
    url: baseUri + "/" + id,
    method: "delete",
  });
}
